package com.asset.dispoal.nature;

import com.asset.dispoal.nature.api.GbNatureService;
import com.asset.dispoal.nature.dto.requset.GbNatureRequest;
import com.asset.dispoal.nature.dto.response.GbNatureResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.controller.BaseController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * 性质管理控制层
 *
 * @author: mhuang
 * @date: 2022-02-25 13:21:21
 */
@RestController
@RequestMapping("gbNature")
@Api(value = "性质管理", tags = "性质管理")
public class GbNatureController extends BaseController {

    @Autowired
    private GbNatureService gbNatureService;

    @Permission(code = "generalCompanyNature:query", param = "create_user")
    @GetMapping(value = "/page")
    @ApiOperation(value = "性质分页查询", notes = "性质分页查询")
    public Result<PageVO<GbNatureResponse>> page(GbNatureRequest request) {
        return gbNatureService.queryPage(request);
    }

    @Permission(code = "generalCompanyNature:add")
    @PostMapping(value = "/insert")
    @ApiOperation(value = "性质分页添加", notes = "性质分页添加")
    public Result insert(@RequestBody GbNatureRequest request) {
        return gbNatureService.insert(request);

    }

    @Permission(code = "generalCompanyNature:update")
    @PutMapping(value = "/update")
    @ApiOperation(value = "性质分页修改", notes = "性质分页修改")
    public Result update(@RequestBody GbNatureRequest request) {
        return gbNatureService.update(request);

    }

    @Permission(code = "generalCompanyNature:del")
    @DeleteMapping(value = "/delete")
    @ApiOperation(value = "性质分页删除", notes = "性质分页删除")
    public Result delete(@RequestBody GbNatureRequest request) {
        gbNatureService.delete(request);
        return Result.ok();
    }


}